<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="stylesheets/index.css" />
    <link rel="stylesheet" type="text/css" href="stylesheets/user.css" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div class="sys_contnt">
    <div class="sys_content_left">
        <ul>
            <li class="sys_content_left_l1"><a href="/group_list" >用户组管理</a></li>
            <li ><a id="useradd" href="/group_add">用户组添加</a></li>
        </ul>
    </div>
    <div class="sys_content_right" >
        <div class="sys_user">
            <h1 class="fleft">用户组管理</h1>
            <form action="groupname" method="post">
                <input type="submit" class="s_sub" value="搜 索"/>
                <input type="text" class="search" name="search" placeholder="请输入用户组名"/>
            </form>
            <table cellpadding="0" border="0" cellspacing="0" class="user clear">
                <tr class="first">
                    <td width="5%"></td>
                    <td width="8%">用户组名</td>
                    <td width="10%">用户组描述</td>
                    <td width="5%">用户组权限</td>

                    <td width="10%">操作</td>
                </tr>
                <%for(var i = 0; i < groupList.length; i++){%>
                <%if(i%2 == 0){%>
                <tr >
                    <td><input type="checkbox" class="checkbox" title="<%= groupList[i]["groupId"]%>"/></td>
                    <td width="5%"><%= groupList[i]["groupName"]%></td>
                    <td width="5%"></td>
                    <td width="8%"><%= groupList[i]["groupPower"]%></td>
                    <td>
                        <ul class="user_table_edit w84">
                            <li><a  class="user_edit"  href="" ></a></li>
                            <li><input type="button" class="user_pwd"></li>
                            <li><input type="button" class="user_del" onclick="deletGroup(<%=groupList[i]["groupId"]%>)"></li>
                        </ul>
                    </td>
                </tr>
                <%}else{%>
                <tr class="double">
                    <td><input type="checkbox" class="checkbox" title="<%= groupList[i]["groupId"]%>"/></td>
                    <td width="5%"><%= groupList[i]["groupName"]%></td>
                    <td width="5%"></td>
                    <td width="8%"><%= groupList[i]["groupPower"]%></td>
                    <td>
                        <ul class="user_table_edit w84">
                            <li><a  class="user_edit"  href="" ></a></li>
                            <li><input type="button" class="user_pwd"></li>
                            <li><input type="button" class="user_del" onclick="deletGroup(<%=groupList[i]["groupId"]%>)"></li>
                        </ul>
                    </td>
                </tr>
                <%}%>
                <%}%>
            </table>
            <div class="div_page2">
                <span class="w5"><input type="checkbox" class="check_all" onchange=""/></span>
                <span><a href="##" class="btn_del" id="batchdel">删 除</a></span>
                <ul class="change" id="pagelist">
                    
                    <li class="pageChange"><a href="">下一页</a></li>
                    
                   
                    <li class="page"><a href=""></a></li>
                   
                    <li class="pageChange"><a href="">上一页</a></li>
                    
                    

                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/javascripts/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/javascripts/jQuery.js"></script>
<script type="text/javascript" src="/routes/group.js"></script>
<script>
    function deletGroup(groupId) {
        if (confirm("确认删除该条数据")){
            $.post("/deletgroup",{groupId:groupId},function (data) {
                alert(data);
                window.history.go(0);
            })
        }
    }
    $("#batchdel").click(function () {
        var choose=[];
        $(":checked").each(function () {
            choose.push($(this).attr("title"));
        })
        $.ajax({
            url:"/delets",
            data:{choose:choose.toString()},
            type:"post",
            success:function (data) {
                alert(data);
                window .history.go(0);
            },
            error:function (err) {
                console.log(err);
            }
        })
    })
    // function deletegroup(groupId){
    //     $.get('/deletegroup',{groupId:groupId},function(data,tip){
    //         if(tip == "success"){
    //             alert("删除成功！");
    //             window.history.go(0);
    //         }
    //         else{
    //             alert("数据库操作失败");
    //         }
    //     })
    // }

    // /*进行批量数据删除*/
    // $("#batchdel").click(function(){
    //     var checkArray = [];
    //     $("table input:checkbox").each(function(){
    //         if($(this).is(":checked")){
    //             checkArray.push($(this).attr("title"));
    //         }
    //     });
    //     console.log(checkArray);
    //     $.ajax({
    //         url:"/deletebatchgroup",
    //         type:"POST",
    //         data:{"groupIdArray":checkArray.toString()},
    //         success:function(data){
    //             alert(data);
    //             window.history.go(0);
    //         }
    //     })
    // })
</script>
</html>